package com.jiazhong.servlet0;

import com.jiazhong.pojo.Brand;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/brandServlet01")
public class BrandServlet01 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Brand> brands = new ArrayList<>();
        brands.add(new Brand(1, "三只松鼠", "三只松鼠", 100, "三只松鼠，好吃不上火", 1));
        brands.add(new Brand(2, "小米", "小米科技有限公司", 1000, "为发烧而生", 1));
        brands.add(new Brand(3, "华为", "华为科技有限公司", 1000, "为发烧而生", 0));
        brands.add(new Brand(4, "格力", "格力科技有限公司", 1000, "为发烧而生", 0));
        brands.add(new Brand(5, "格力", "格力科技有限公司", 1000, "为发烧而生", 0));
        //把数据放在请求域对向中
        req.setAttribute("brands", brands);
        //请求转发至el-demo的jsp的页面
      /*  final RequestDispatcher requestDispatcher = req.getRequestDispatcher("/EL/EL_Demo01.jsp");
        requestDispatcher.forward(req, resp);*/
        //请求转发至jstlif的jsp的页面
        final RequestDispatcher requestDispatcher1 = req.getRequestDispatcher("/JstlIf/JstlIf.jsp");
        requestDispatcher1.forward(req, resp);
    }
}
